package org.gwt.grin.rebind.features;

import java.util.Formatter;

import org.gwt.grin.client.features.InterpolatedModel;
import org.gwt.grin.rebind.SECommand;
import org.gwt.grin.rebind.SEFeature;
import org.gwt.grin.rebind.ShowBuilder;

public class SEScalingModel extends SEFeature {

	private final int[] frames;
	private final int[][] values;
	private final int repeatFrame;
	private final int loopCount;
	private final SECommand[] endCommands;
	private final boolean dynScaleX;
	private final boolean dynScaleY;

	public SEScalingModel(String name, int[] frames, int[][] values,
			int repeatFrame, int loopCount, SECommand[] endCommands,
			boolean dynScaleX, boolean dynScaleY) {
		super(name);
		this.frames = frames;
		this.values = values;
		this.repeatFrame = repeatFrame;
		this.loopCount = loopCount;
		this.endCommands = endCommands;
		this.dynScaleX = dynScaleX;
		this.dynScaleY = dynScaleY;
	}

	@Override
	public String write(ShowBuilder builder) {
		Formatter formatter = new Formatter();
		formatter.format(
				"makeScalingModel(\"%s\", %s, %s, %d, %d, %s, %b, %b)", name,
				makeIntArray(frames), makeIntArray(values), repeatFrame,
				loopCount, makeCommandsArray(builder, endCommands), dynScaleX,
				dynScaleY);
		return formatter.toString();
	}

	@Override
	protected String getClassName() {
		return InterpolatedModel.class.getName();
	}

}
